package com.zhangrui.dao;

import com.zhangrui.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName:UserMapper
 * Package:com.zhangrui.dao
 * Description:
 *
 * @Date:2021/8/1520:36
 * @Author:zhangrui@qq.com
 */
//该映射接口专门学习注解的
public interface UserMapper {
    //查询数据
    @Select("select * from mysql.zhangrui")
    List<User> getUserList();

    //通过id查询一条数据
    //注意：@Param注解在只有一个参数时，可以省略不写，多个参数时，必须加上该注解
    @Select("select * from mysql.zhangrui where id = #{id} and name = #{name}")
    User getUserId(@Param("id") int id, @Param("name") String name);

    //新增一条数据
    @Insert("insert into mysql.zhangrui (id,name,pwd) values (#{id},#{name},#{pwd})")
    Integer getAddUser(User user);

    //修改一条数据
    @Update("update mysql.zhangrui set pwd = #{pwd} where id = #{id} and name = #{name}")
    Integer getUpUser(@Param("id") int id, @Param("name") String name, @Param("pwd") String pwd);

    //删除一条数据
    @Delete("delete from mysql.zhangrui where pwd = #{pwd}")
    Integer getDeleUser(String pwd);
}
